package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.PageRequestDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/v1/channel")
public class WmchannelController {

    @Autowired
    private WmChannelService wmChannelService;

    @GetMapping("/channels")
    public ResponseResult findAll() {
        return wmChannelService.findAll();
    }

    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmChannel wmChannel) {

        return wmChannelService.saveNotRepeat(wmChannel);
    }

    @PostMapping("/list")
    public ResponseResult list(@RequestBody PageRequestDto dto) {
        return wmChannelService.listPage(dto);
    }

    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmChannel wmChannel  ) {
        return wmChannelService.update(wmChannel);
    }

    @GetMapping("/del/{id}")
    public ResponseResult del(@PathVariable Integer id){
        return wmChannelService.del(id);
    }
}
